<template>
	<view>
		<view class="mainpadding ffffff margin_top1">
			<view class=" flexbetween margin_top2" :class="recharge_item_id==item.id?'yixzbox':'weixbox'"  v-for="item in czxlist" :key="item.id" @click="recharge_item_id=item.id;recharge_item_price=item.price">
				<view class="xiaoka sanshier fonweight textcenter">{{item.price}}</view>
				<view class="xiaohui ershiba nofonweight margin_top1 textcenter">充{{item.price}}送{{item.send_price}}元</view>
			</view>
			<view class="gudingdb mainpadding">
				<view class="bigbtn" @click="chongzhi">充值</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				dataAll:{},
				czxlist:[],
				type:0,//0我的余额充值，1我的某一个会员卡的余额充值
				recharge_item_id:"",
				recharge_item_price:"",
			}
		},
		onLoad(options) {
			this.type = options.type
			this.listid = options.id
			if(this.type==0){
				this.getczx()
			}
			if(this.type==1){
				this.getDetail()
			}
		},
		methods: {
			chongzhi(){
				if(this.recharge_item_id==""){
					httpRequest.toast("请选择充值项")
					return false
				}
				let data = {
					recharge_item_id:this.recharge_item_id,
					recharge_item_price:this.recharge_item_price,
					type:this.type,
				}
				uni.navigateTo({
					url:"/pages_mypage/chongzhi?msg=" + encodeURIComponent(JSON.stringify(data))
				})
				
			},
			getDetail() {
				httpRequest.request("/api/user/userHycardDetail", 'GET', {
					id: this.listid
				}, false, false, true).then(res => {
					this.dataAll = res.data
					this.getczx()
				})
			},
			getczx() {
				let data = {}
				let url = "/api/Rechargeorder/rechargePtItemIndex"
				if(this.type==1){//会员卡充值项
					url = "/api/user/hyCardRechargeItem"
					data = {
						user_zbfapply_id: this.dataAll.user_zbfapply_id
					}
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					this.czxlist = res.data
					if(res.data.length){
						this.recharge_item_id = res.data[0].id
						this.recharge_item_price = res.data[0].price
					}
					
				})
			},
		}
	}
</script>

<style lang="scss" scope>
	.yixzbox {
		background: #FFF7E9;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 34rpx 21rpx;
		border: 2rpx solid #E3C385;
	}

	.weixbox {
		background: #F9F9F9;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 34rpx 21rpx;
		border: 2rpx solid #F9F9F9;
	}
</style>